#include <kuai/misc/error.hpp>
#include <kuai/sim/simio.hpp>
#include <kuai/mol/inchi.hpp>
#include <kuai/test/testINCHI.hpp>


namespace kuai {

	IMPLEMENT_JOB_CREATOR(TestSDFInchiJob, Test sdf inchi);

	void TestSDFInchiJob::doJob(std::ostream& osOutput, std::ostream& osError, StringMap& par) 
	{
		std::ifstream sdf;
		tryOpen(sdf, FileName(getParameter(par, "sdf", "")));

		MDLMolReader reader;
		PhaseSpace space;
		size_t n = 0;
		String line;
		while (reader.read(sdf, space)) {
			String inchiset[4];
			inchi(space, "", inchiset);
			osOutput 
				<< "Structure: " << ++n << std::endl
				<< inchiset[0] << std::endl
				<< inchiset[1] << std::endl
				<< "InChIKey=" << inchikey(inchiset[0].c_str()) << std::endl;
			while (getline(sdf, line) && line != "$$$$") 
			{ }
		}
	}

	JOB_HELP_FUNCTION(TestSDFInchiJob, output) {
	
	}

}
